package com.jsbb.controller.common;

import com.jsbb.annotation.ApiLog;
import com.jsbb.common.Message;
import com.jsbb.service.common.FileService;
import com.jsbb.vo.common.FileVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件Controller
 *
 * @author w
 * @date 2021-03-05
 */
@Slf4j
@RestController
@RequestMapping("/common/file")
@ApiLog("文件")
@Api(tags = {"公共模块-文件"})
public class FileController {

    @Autowired
    private FileService fileService;

    @ApiOperation(value = "上传")
    @PostMapping("/upload")
    public Message<FileVo> upload(@ApiParam(name = "file", value = "文件", required = true) MultipartFile file) throws Exception {
        FileVo fileVo = fileService.upload(file);
        return Message.success(fileVo);
    }
}
